package com.dongdongshop.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;

@Configuration
public class FreemakerConfig {

    @Value("${myFreemarker.templateLoaderPath}")
    private String path;

    @Value("${myFreemarker.tefaultEncoding}")
    private String tefaultEncoding;

    @Bean
    public FreeMarkerConfigurer freeMarkerConfigurer(){
        //创建对象
        FreeMarkerConfigurer configurer = new FreeMarkerConfigurer();
        //设置模板加载路径
        configurer.setTemplateLoaderPath(path);
        //设置编码
        configurer.setDefaultEncoding(tefaultEncoding);
        //
        return configurer;
    }
}
